package com.block.datapush.service.extdata;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.block.datapush.model.ProtocolInfoEntity;
import com.block.datapush.service.IPushExtDataService;
import com.block.db.entity.MemberSourceInfo;
import com.block.db.entity.MerchantBaseInfo;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QiDaiPushExtDataServie implements IPushExtDataService {

    @Override
    public List<ProtocolInfoEntity> getProtocolUrl(MerchantBaseInfo merchantBaseInfo, MemberSourceInfo memberSourceInfo, JSONObject extObject) {

        List<ProtocolInfoEntity> protocolList = new ArrayList<>();
        if (StrUtil.isNotEmpty(merchantBaseInfo.getApiProtocolUrl())){
            String protocolUrl = StrUtil.format(merchantBaseInfo.getApiProtocolUrl(), memberSourceInfo.getMobileMd5());

            ProtocolInfoEntity infoEntity = new ProtocolInfoEntity();
            infoEntity.setProtocolUrl(protocolUrl);
            infoEntity.setProtocolName("授权协议");

            protocolList.add(infoEntity);
        }
        return protocolList;
    }
}
